package enum

type Code int

const (
	// SUCCESS 成功
	SUCCESS Code = 200

	// ERROR 失败
	ERROR Code = 500

	// code = 1xxx 用户模块的错误

	ErrorUsernameUsed   Code = 1001
	ErrorPasswordWrong  Code = 1002
	ErrorUserNotExist   Code = 1003
	ErrorTokenNotExist  Code = 1004
	ErrorTokenRuntime   Code = 1005
	ErrorTokenWrong     Code = 1006
	ErrorTokenTypeWrong Code = 1007
	ErrorUserNoRight    Code = 1008
	ErrorPasswordRepeat Code = 1009

	// code = 2xxx 文章模块的错误

	ErrorArtNotExist Code = 2001

	// code = 3xxx 分类模块的错误

	ErrorCatenameUsed Code = 3001
	ErrorCateNotExist Code = 3002
)

func (c Code) String() string {
	switch c {
	case SUCCESS:
		return "OK"
	case ERROR:
		return "FAIL"
	case ErrorUsernameUsed:
		return "用户名已存在"
	case ErrorPasswordWrong:
		return "密码错误"
	case ErrorUserNotExist:
		return "用户不存在"
	case ErrorTokenNotExist:
		return "TOKEN不存在"
	case ErrorTokenRuntime:
		return "TOKEN已过期"
	case ErrorTokenWrong:
		return "TOKEN不正确"
	case ErrorTokenTypeWrong:
		return "TOKEN格式错误"
	case ErrorUserNoRight:
		return "该用户无权限"
	case ErrorPasswordRepeat:
		return "不能与原始密码一致"
	case ErrorArtNotExist:
		return "该文章不存在"
	case ErrorCatenameUsed:
		return "该分类已存在"
	case ErrorCateNotExist:
		return "该分类不存在"
	default:
		return "UNKNOWN"
	}
}
